
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
About tracing and profiling an application</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="pbugp266.htm">Previous</A>&nbsp;&nbsp;<A HREF="pbugp268.htm" >Next</A>
<!-- End Header -->
<A NAME="CAICEDBJ"></A><h1>About tracing and profiling an application</h1>
<A NAME="TI9731"></A><p>You use tracing and profiling to debug and tune an application.
When you run an application, you can generate an execution trace
file. You use the trace file to create a profile of your application. </p>
<A NAME="TI9732"></A><p>The profile shows you which functions and events were called
by which other functions and events, how often they were called,
when garbage collection occurred, when objects were created and
destroyed, and how long each activity took to complete. This information
helps you find errors in the application's logic and identify
areas that you should rewrite to improve performance.</p>
<p><img src="images/note.gif" width=17 height=17 border=0 align="bottom" alt="Note"> <span class=shaded>PBDebug tracing</span> <A NAME="TI9733"></A>You can also generate a simple text trace file without timer
values by checking Enable PBDebug Tracing in the System Options
dialog box.</p>
<A NAME="TI9734"></A>For more about PBDebug, see <A HREF="pbugp271.htm#BFCDAGIA">"Generating a trace file
without timing information"</A>.</p>
<A NAME="TI9735"></A><h4>When you can trace an application</h4>
<A NAME="TI9736"></A><p>You can create a trace file when you run an application in
the PowerBuilder environment, and when you run an executable outside
PowerBuilder. For machine-code executable files, the trace file
is generated only if you check the Trace Information check box when
you build the executable.</p>
<A NAME="TI9737"></A><p>When you run an application with tracing turned on, PowerBuilder
records a timer value in a data file every time a specific activity
occurs. You control when logging begins and ends and which activities
are recorded.</p>
<A NAME="TI9738"></A><h4>Creating profiles</h4>
<A NAME="TI9739"></A><p>After you have generated a trace file, you can create several
different profiles or views of the application by extracting different
types of information from the trace file. </p>
<A NAME="TI9740"></A><p>PowerBuilder provides three profiling tools that create profiles
(views) of the application for you, but you can also create your
own analysis tools.</p>
<A NAME="TI9741"></A><h4>Using profiling to tune an application</h4>
<A NAME="TI9742"></A><p>Examining the profiles generated by the profiling tools tells
you where the application is spending the most time. You can also
find routines that are being called too often, routines being called
that you did not expect to call, or routines that are not being
called at all. Follow these suggestions for tuning an application:<A NAME="TI9743"></A>
<ul>
<li class=fi>The database connection process is often slow. Although
you might not be able to speed this up, you might be able to enhance
the user's perception of performance by moving the database
connection process to a different place in your application.</li>
<li class=ds>Use profiling to tune algorithms. Algorithmic fixes
will yield greater performance enhancements than changing single
lines of code.</li>
<li class=ds>Optimizing an inefficient function is not as effective
as removing unneeded calls to that function.</li>
<li class=ds>Focus on optimizing the routines that are called
most often.</li>
<li class=ds>If you cannot speed up a routine, consider adding
some user feedback, such as updating MicroHelp or displaying a progress
bar.
</li>
</ul>
</p>

